Repository navigation
Conversation
The SQL result cache fell back to pickle in both directions: results that Parquet can't hold were uploaded as pickles, and cache objects that weren't Parquet were loaded with pandas.read_pickle. Unpickling downloaded bytes runs whatever code they contain, so the cache now holds Parquet only. - upload_sql_cache skips the upload and logs a warning (result_not_parquet_serializable) when to_parquet fails. - A cache hit whose object isn't Parquet is ignored with a warning (cache_object_not_parquet), and the query runs against the warehouse. - pyarrow >= 14.0.1 on Python 3.10 and 3.11 outside macOS, the release that fixes CVE-2023-47248. Only poetry.lock's content-hash changes: the locked pyarrow versions already satisfy the floor.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
📦 Python package built successfully!
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
==========================================
- Coverage 78.57% 78.56% -0.01%
==========================================
Files 121 121
Lines 6935 6932 -3
Branches 1009 1009
==========================================
- Hits 5449 5446 -3
- Misses 1179 1181 +2
+ Partials 307 305 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
🚀 Review App Deployment Started
|
Summary
The SQL result cache fell back to pickle in both directions.
upload_sql_cacheuploaded a pickle when a result couldn't be written as Parquet, and_try_read_cacheloaded any cache object that wasn't Parquet withpandas.read_pickle. Unpickling downloaded bytes runs whatever code they contain, so this PR makes the cache Parquet-only:to_parquetraisesArrowNotImplementedError,ArrowInvalidorOverflowError, the toolkit logs a warning withsql_caching_cause: "result_not_parquet_serializable"and doesn't upload. The notebook still gets the result. Other upload failures are logged as before (failed_to_upload_to_cache).ArrowInvalid) is ignored. The toolkit logs a warning withsql_caching_cause: "cache_object_not_parquet", doesn't emitread_from_cache_success, and runs the query against the warehouse. Other download errors are still logged asfailed_to_download_from_cache.get_sql_cache, the webapp request, cache keys and the presigned-URL logging are unchanged.Behavior changes
Lock
Only
content-hashchanges inpoetry.lock. The locked pyarrow versions (16.1.0 for Python < 3.12, 24.0.0 for 3.12+) already satisfy>=14.0.1. A fullpoetry lockwith Poetry 2.2.0 rewrites about 1,180 unrelated lines, even on unchangedmain, so this follows #143, #145 and #146. Those PRs also kept only the relevant changes and the new hash.poetry check --lockpasses, andpoetry install --dry-runinstalls nothing new.Tests
test_fallback_to_pickle_formatwithtest_pickle_cache_object_is_cache_miss. A real pickle file is served as the cache hit, with the realread_parquet/read_pickle.test_overflow_error_falls_back_to_picklewithtest_result_parquet_cannot_hold_is_not_uploaded. It is parameterized over one input per caught exception: an int beyond int64 (OverflowError), a mixed int/str column (ArrowInvalid) and a complex column (ArrowNotImplementedError).test_pickle_fallback_truncates_partial_parquet_bytes, because the behavior it covered is gone.test_read_from_cache_error_doesnt_raise. It never reached the readers, because its unpatched webapp request failed first.test_failed_to_download_from_cachenow asserts that thefailed_to_download_from_cacheerror is logged. Without that check, widening the read'sexcept ArrowInvalidtoexcept Exceptionpassed every test.main'ssql_caching.pyfor the intended reason. Mutating the new code is caught in each case: re-adding the pickle read, removing the early return before the PUT, dropping any of the three exception types, logging at a different level, and droppingerror_type.tests/unit/test_sql_caching.py: 36 passed.ArrowInvalidfromread_parquet.Docs
docs/sql-query-caching.mdin deepnote/deepnote lists when caching isn't applied. It needs a new line saying results that can't be stored as Parquet aren't cached: deepnote/deepnote#693, to merge after this PR is released.